
using System;
using TripleA.Core.Interfaces.Exceptions;

namespace TripleA.Core.Extensions.WindowsService
{
    /// <summary>
    /// This asserts the windows service has the expected identity
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class WindowsServiceRunningAsStep<T> : WindowsServiceWmiStepBase<T>
    {
        public string Identity{ get; set; }

        protected override void InspectService(ServiceInfo service)
        {
            if (string.Compare(Identity, service.Identity, StringComparison.OrdinalIgnoreCase) != 0)
                throw new ExpectationException("Service '{0}' is running under identity '{1}', expected '{2}'",
                    ServiceName, service.Identity, Identity);
        }
    }
}